<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org/">
<head>
    <meta charset="UTF-8">
    <title>用户注册</title>
    <base href="http://localhost/shop-resources/front/">

    <link rel="stylesheet" type="text/css" href="css/style.css" />
    <link rel="stylesheet" type="text/css" href="css/shopping-mall-index.css" />
    <script type="text/javascript" src="js/jquery.js"></script>
    <script type="text/javascript" src="js/zhonglin.js"></script>

    <link href="http://localhost/shop-resources/back/css/H-ui.min.css" rel="stylesheet" type="text/css"/>
    <link href="http://localhost/shop-resources/back/css/H-ui.admin.css" rel="stylesheet" type="text/css"/>
    <link href="http://localhost/shop-resources/back/lib/Hui-iconfont/1.0.1/iconfont.css" rel="stylesheet" type="text/css"/>

</head>
<body>

<!--top 开始-->
<div class="top">
    <div class="top-con w1200">
        <p class="t-con-l f-l">您好，欢迎来到宅客微购</p>
        <ul class="t-con-r f-r">
            <li><a href="#">我 (个人中心)</a></li>
            <li><a href="#">我的购物车</a></li>
            <li><a href="#">我的订单</a></li>
            <li class="erweima">
                <a href="#">扫描二维码</a>
                <div class="ewm-tu">
                    <a href="#"><img src="images/erweima-tu.jpg" /></a>
                </div>
            </li>
            <div style="clear:both;"></div>
        </ul>
        <div style="clear:both;"></div>
    </div>
</div>

<!--logo search 开始-->
<div class="hd-info1 w1200">
    <div class="logo f-l">
        <h1><a href="#" title="中林网站"><img src="images/logo.jpg" /></a></h1>
    </div>
    <div class="search f-r">
        <ul class="sp">
            <li class="current" ss-search="sp"><a href="JavaScript:;">商品</a></li>
            <li ss-search="dp"><a href="JavaScript:;">店铺</a></li>
            <div style="clear:both;"></div>
        </ul>
        <div class="srh">
            <div class="ipt f-l">
                <input type="text" placeholder="搜索商品..." ss-search-show="sp" />
                <input type="text" placeholder="搜索店铺..." ss-search-show="dp" style="display:none;" />
            </div>
            <button class="f-r">搜 索</button>
            <div style="clear:both;"></div>
        </div>
        <ul class="sp2">
            <li><a href="#">绿豆</a></li>
            <li><a href="#">大米</a></li>
            <li><a href="#">驱蚊</a></li>
            <li><a href="#">洗面奶</a></li>
            <li><a href="#">格力空调</a></li>
            <li><a href="#">洗发护发</a></li>
            <li><a href="#">葡萄 </a></li>
            <li><a href="#">脉动</a></li>
            <li><a href="#">海鲜水产</a></li>
            <div style="clear:both;"></div>
        </ul>
    </div>
    <div style="clear:both;"></div>
</div>

<!--内容开始-->
<div class="pd-20">
    <form action="abc" method="post" class="form form-horizontal" id="form-user-register">
        <div class="row cl">
            <label class="form-label col-3"><span class="c-red">*</span>用户名：</label>
            <div class="formControls col-2">
                <input type="text" class="input-text" value="赵莉"
                       placeholder="" id="username" name="username" datatype="*2-16"
                       nullmsg="用户名不能为空" ajaxurl="http://localhost/auth/user/checkUsername">
                <!--ajaxurl 异步请求:验证姓名不能为空-->
            </div>
            <div class="col-4"></div>
        </div>

        <div class="row cl">
            <label class="form-label col-3"><span class="c-red">*</span>密码：</label>
            <div class="formControls col-2">
                <input type="password" placeholder="密码" name="password" autocomplete="off" value="12345678"
                       class="input-text"
                       datatype="*5-20" nullmsg="密码不能为空">

            </div>
            <div class="col-4"></div>
        </div>

        <div class="row cl">
            <label class="form-label col-3"><span class="c-red">*</span>确认密码：</label>
            <div class="formControls col-2">
                <input type="password" placeholder="密码" name="repassword" autocomplete="off" value="12345678"
                       recheck="password"
                       class="input-text" datatype="*" nullmsg="密码不能为空">
            </div>
            <div class="col-4"></div>
        </div>
<!--        13480743212-->
        <div class="row cl">
            <label class="form-label col-3"><span class="c-red">*</span>手机：</label>
            <div class="formControls col-2">
                <input type="text" class="input-text" value="13627085815" placeholder="" id="phone" name="phone"
                       datatype="m" nullmsg="手机不能为空">
            </div>
            <div class="col-2"></div>
        </div>
        <div class="row cl">
            <label class="form-label col-4">
                <input onclick="sendCode()" id="sms-text" type="button" class="btn btn-primary radius" value="获取验证码">
            </label>
        </div>
        <div class="row cl">
            <label class="form-label col-3"><span class="c-red">*</span>验证码：</label>
            <div class="formControls col-2">
                <input type="text" class="input-text"  placeholder="" id="code" name="code"
                       datatype="n" nullmsg="验证码不能为空">
            </div>
            <div class="col-2"></div>
        </div>

        <div class="row cl">
            <label class="form-label col-3"><span class="c-red">*</span>邮箱：</label>
            <div class="formControls col-2">
                <input type="text" class="input-text" value="973125285@qq.com" placeholder="@" name="email" id="email"
                       datatype="e" nullmsg="请输入邮箱！">
            </div>
            <div class="col-4"></div>
        </div>
        <div class="row cl">
            <div class="col-9 col-offset-3">
                <input class="btn btn-primary radius" type="submit" value="&nbsp;&nbsp;提交&nbsp;&nbsp;">
            </div>
        </div>
    </form>
</div>

<!--底部服务-->
<div class="ft-service">
    <div class="w1200">
        <div class="sv-con-l2 f-l">
            <dl>
                <dt><a href="#">新手上路</a></dt>
                <dd>
                    <a href="#">购物流程</a>
                    <a href="#">在线支付</a>
                </dd>
            </dl>
            <dl>
                <dt><a href="#">配送方式</a></dt>
                <dd>
                    <a href="#">货到付款区域</a>
                    <a href="#">配送费标准</a>
                </dd>
            </dl>
            <dl>
                <dt><a href="#">购物指南</a></dt>
                <dd>
                    <a href="#">常见问题</a>
                    <a href="#">订购流程</a>
                </dd>
            </dl>
            <dl>
                <dt><a href="#">售后服务</a></dt>
                <dd>
                    <a href="#">售后服务保障</a>
                    <a href="#">退款说明</a>
                    <a href="#">新手选购商品总则</a>
                </dd>
            </dl>
            <dl>
                <dt><a href="#">关于我们</a></dt>
                <dd>
                    <a href="#">投诉与建议</a>
                </dd>
            </dl>
            <div style="clear:both;"></div>
        </div>
        <div class="sv-con-r2 f-r">
            <p class="sv-r-tle">187-8660-5539</p>
            <p>周一至周五9:00-17:30</p>
            <p>（仅收市话费）</p>
            <a href="#" class="zxkf">24小时在线客服</a>
        </div>
        <div style="clear:both;"></div>
    </div>
</div>

<!--底部 版权-->
<div class="footer w1200">
    <p>
        <a href="#">关于我们</a><span>|</span>
        <a href="#">友情链接</a><span>|</span>
        <a href="#">宅客微购社区</a><span>|</span>
        <a href="#">诚征英才</a><span>|</span>
        <a href="#">商家登录</a><span>|</span>
        <a href="#">供应商登录</a><span>|</span>
        <a href="#">热门搜索</a><span>|</span>
        <a href="#">宅客微购新品</a><span>|</span>
        <a href="#">开放平台</a>
    </p>
    <p>
        沪ICP备13044278号<span>|</span>合字B1.B2-20130004<span>|</span>营业执照<span>|</span>互联网药品信息服务资格证<span>|</span>互联网药品交易服务资格证
    </p>
</div>

</body>
<script type="text/javascript" src="http://localhost/shop-resources/back/lib/Validform/5.3.2/Validform.min.js"></script>
<script type="text/javascript" src="http://localhost/shop-resources/back/lib/layer/1.9.3/layer.js"></script>
<script type="text/javascript" src="http://localhost/shop-resources/back/js/AjaxUtil.js"></script>
<script type="text/javascript">
    // 手机号码正则验证
    var reg_tel = /^(13[0-9]|14[01456879]|15[0-35-9]|16[2567]|17[0-8]|18[0-9]|19[0-35-9])\d{8}$/;

    function sendCode() {
        var phone = $("#phone").val();
        if (!phone){
            layer.msg("请输入手机号码");
            return;
        }
        if (!reg_tel.test(phone)){
            layer.msg("手机号码格式不正确,请重新输入");
            return;
        }
        var msgText = $("#sms-text");
        // 设置提示信息
        msgText.val("验证码已发送，请注意查收(60s)");
        msgText.prop("disabled",true);
        //开始计时
        time();
        //异步请求,后台发送验证码
        var url = "auth/user/sendSms/"+phone;
        get(url,function () {
            // 回调函数,处理业务
        })
    }

    var t = 60;

    // 验证码倒计时函数
    function time(){
        var msgText = $("#sms-text");
        t--;
        // 时间到0后停止计时
        if (t<=0){
            msgText.prop("disabled",false);
            msgText.val("重新获取验证码");
            t = 60;
            return;
        }

        msgText.val("验证码已发送,请注意查收("+t+")s");
        setTimeout(function () {
            time();
        },1000);
    }

    $(function () {
        $("#form-user-register").Validform({
            tiptype: 2,
            callback: function (form) {
                // 异步请求--->业务处理
                var param = formToObject(form);
                send("auth/user/registerUser",param,function (data) {
                    if (data.status=="success"){
                        layer.msg("注册成功",{icon: 1,time: 1000},function () {
                        //    注册成功跳转到登录页面
                            location.href = "http://localhost/auth/login.html";
                        });
                    }else {
                        layer.msg(data.msg,{icon: 2,time: 1000});
                    }
                });
                // 设置表单不提交
                return false;
            }
        })
    })

</script>
</html>